<template>
	<view class="u-flex user-box u-p-t-30 u-p-l-30 u-p-r-20 u-p-b-30" @click="clickUserBox">
		<view class="u-m-r-10">
			<u-avatar :src="userInfo.avatarUrl ? userInfo.avatarUrl: pic" size="140"></u-avatar>
		</view>
		<view class="u-flex-1">
			<view class="u-font-18 u-p-b-20">{{userIsLogin ? (userInfo.info_name ? userInfo.info_name: '未定义') : '登录'}}</view>
			<!-- <view v-if="userIsLogin" class="u-font-14 u-tips-color">微信号:uduemc</view> -->
		</view>
		<!-- <view class="u-m-l-10 u-p-10">
			<u-icon name="scan" color="#969799" size="28"></u-icon>
		</view> -->
		<view class="u-m-l-10 u-p-10">
			<u-icon name="arrow-right" color="#969799" size="28"></u-icon>
		</view>
	</view>
</template>

<script>
	import UserForm from '@/common/UserForm.js'
	import {
		mapGetters
	} from 'vuex'
	export default {
		name: 'g-my-user-box',
		computed: {
			...mapGetters(['userIsLogin']),
			...mapGetters(['userInfo'])
		},
		data() {
			console.log(this.userInfo)
			return {
				pic: require('@/static/images/photoempty.png')
			}
		},
		mounted() {},
		methods: {
			// 点击用户框体，如果未登录进入登录页面，如果登录进入用户详情编辑页面
			clickUserBox() {
				if (this.userIsLogin === true) {
					// 进入用户详情编辑页面
					UserForm.vLogin(() => {
						// 验证是否登录
						uni.navigateTo({
							url: '/pages/user/info'
						})
					})
				} else {
					// 进入登录页面
					uni.navigateTo({
						url: '/pages/public/login'
					});
				}
			}
		}
	}
</script>

<style scoped lang="scss">
</style>
